package cn.appsys.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.appsys.pojo.DevUser;
import cn.appsys.serivce.Dev_UserSerivce;

@Controller
@RequestMapping("/dev")
public class DevController {
	Logger logger=Logger.getLogger(DevController.class);
	
	@Resource(name="Dev_UserSerivce")
	private Dev_UserSerivce devUserSerivce;
	
	@RequestMapping("/login")
	public String Login() {
		logger.debug("Login================");
		return "WEB-INF/jsp/devlogin";
	}
	
	@RequestMapping("/login.do")
	public String Login_do(String devCode,String devPassword,HttpSession session) {
		logger.debug("Login_do======(devCode:"+devCode+" | devPassword:"+devPassword+")");
		DevUser devUser=devUserSerivce.logindo(devCode, devPassword);
		
		//如果是空的 回登录页面 
		//如果不是空的 就是登录成功 值放session里 进入下一个页面
		if(devUser==null) {
			return "WEB-INF/jsp/devlogin";
		}
		
		session.setAttribute("devUserSession", devUser);
		return "";
	}
}
